//
//	_MiscMergeDelayedParseCommand.m -- delayed merge command implementation
//		Written by Don Yacktman Copyright (c) 1995 by Don Yacktman.
//				Version 1.0.  All rights reserved.
//		This notice may not be removed from this source code.
//
//	This object is included in the MiscKit by permission from the author
//	and its use is governed by the MiscKit license, found in the file
//	"LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
//	for a list of all applicable permissions and restrictions.
//	


#import <misckit/miscmerge.h>
#import "_MiscMergeDelayedParseCommand.h"

@implementation _MiscMergeDelayedParseCommand

- parseFromString:(MiscString *)aString
{ // hold onto the text until we're actually merging...
	unparsedCommand = [aString copy]; 
	return self;
}

- executeForMerge:(MiscMergeEngine *)aMerger
{
	MiscString *result;
	MiscMergeCommand *theCommand;
	MiscMergeTemplate *template =
			[[MiscMergeTemplate alloc] initWithString:unparsedCommand];
	MiscMergeEngine *anEngine = [[MiscMergeEngine alloc] init];

	[anEngine setTemplate:template];
	[anEngine setParentMerge:aMerger];
	[anEngine setMergeDictionary:[aMerger dictionary]];
	result = [anEngine merge:self];
	theCommand = [[[MiscMergeTemplate getClassForCommand:result]
				alloc] initFrom:result];
	[theCommand executeForMerge:aMerger];
	[result free];
	[theCommand free];
	[template free];
	[anEngine free];
	return self;
}

@end



